import React from 'react';
import styles from './RightPannel.less';
import classNames from 'classnames';
import { connect } from 'umi';
import WorkView from './WorkView';
import VerifyView from './VerifyView';
import EdgeView from './EdgeView';
import { EventItemType } from '../dict';

function RightPannel(props) {
  const { wfeditor, appId } = props;
  const { selectedId, selectedType, selectedObj } = wfeditor;

  const nodeView = () => {
    if (selectedId && selectedType && selectedType === EventItemType.WorkTask)
      return <WorkView appId={appId} />;
    if (selectedId && selectedType && selectedType === EventItemType.VerifyTask)
      return <VerifyView appId={appId} />;
    if (selectedId && selectedType && selectedType === EventItemType.Edge)
      return <EdgeView appId={appId} />;
    return null;
  };

  return <div className={styles.rightPannel}>{nodeView()}</div>;
}

export default connect(({ wfeditor }) => ({ wfeditor }))(RightPannel);
